package cn.migu.music.hangupsms.common.config;

/**
 * @version 1.0 created by duanhao@migu.cn on 2022/3/8 11:17 上午
 */
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 提供静态访问 CenterMusicHttpConfig 配置的方法
 */

@Component
public class CenterMusicHttpConfigAdapter implements ApplicationContextAware {

    /**
     * Spring 应用上下文
     */
    private static ApplicationContext context = null;

    @Override
    public void setApplicationContext(ApplicationContext arg0) {
        setApplicationContextStatic(arg0);
    }

    private static void setApplicationContextStatic(ApplicationContext arg0) {
        context = arg0;
    }

    public static String getSecretKey() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getSecretKey();
    }

    public static String getCardCouponSecretKey() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getCardCouponSecretKey();
    }

    public static String getPartner() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getPartner();
    }

    public static String getDid() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getDid();
    }

    public static String getCardCouponSignType() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getCardCouponSignType();
    }

    public static String getPwd() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getCenterPass();
    }

    public static String getRole() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getRole();
    }

    public static String getRoleCode() {
        CenterMusicHttpConfig config = context.getBean(CenterMusicHttpConfig.class);
        return config.getRoleCode();
    }
}
